all:son/son sip/sip client/stress_client.out client/simple_client.out server/simple_server.out server/stress_server.out
common/pkt.o: common/pkt.c common/pkt.h common/constants.h
	gcc -Wall -g -c common/pkt.c -o common/pkt.o

common/seg.o: common/seg.c common/constants.h
	gcc -Wall -g -c common/seg.c -o common/seg.o

common/common.o: common/common.c
	gcc -Wall -g -c common/common.c -o common/common.o

topology/topology.o: topology/topology.c
	gcc -Wall -g -c topology/topology.c -o topology/topology.o

son/neighbortable.o: son/neighbortable.c
	gcc -Wall -g -c son/neighbortable.c -o son/neighbortable.o

utils/concurrent.o:utils/concurrent.c
	gcc -Wall -g -c -pthread  utils/concurrent.c -o utils/concurrent.o

sip/dvtable.o: sip/dvtable.c
	gcc -Wall -g -c sip/dvtable.c -o sip/dvtable.o

sip/nbrcosttable.o:sip/nbrcosttable.c
	gcc -Wall -g -c sip/nbrcosttable.c -o sip/nbrcosttable.o

sip/routingtable.o:sip/routingtable.c
	gcc -Wall -g -c -pthread sip/routingtable.c -o sip/routingtable.o

son/son: topology/topology.o common/pkt.o common/common.o utils/concurrent.o son/neighbortable.o son/son.c 
	gcc -Wall -g -pthread son/son.c topology/topology.o common/pkt.o common/common.o son/neighbortable.o utils/concurrent.o -o son/son

sip/sip: common/pkt.o common/seg.o common/common.o topology/topology.o utils/concurrent.o sip/dvtable.o sip/nbrcosttable.o sip/routingtable.o sip/sip.c 
	gcc -Wall -g -pthread sip/sip.c topology/topology.o common/seg.o common/pkt.o common/common.o utils/concurrent.o sip/dvtable.o sip/nbrcosttable.o sip/routingtable.o -o sip/sip 


client/simple_client.out:topology/topology.o  common/seg.o common/pkt.o common/common.o utils/concurrent.o
	gcc -Wall -g -pthread client/app_simple_client.c client/stcp_client.c  topology/topology.o common/seg.o common/pkt.o common/common.o utils/concurrent.o -o client/simple_client.out

server/simple_server.out:topology/topology.o  common/seg.o common/pkt.o common/common.o utils/concurrent.o
	gcc -Wall -g -pthread server/app_simple_server.c server/stcp_server.c  topology/topology.o common/seg.o common/pkt.o common/common.o utils/concurrent.o -o server/simple_server.out

client/stress_client.out:topology/topology.o  common/seg.o common/pkt.o common/common.o utils/concurrent.o client/app_stress_client.c client/stcp_client.c
	gcc -Wall -g -pthread client/app_stress_client.c client/stcp_client.c  topology/topology.o common/seg.o common/pkt.o common/common.o utils/concurrent.o -o client/stress_client.out

server/stress_server.out:topology/topology.o  common/seg.o common/pkt.o common/common.o utils/concurrent.o server/app_stress_server.c server/stcp_server.c
	gcc -Wall -g -pthread server/app_stress_server.c server/stcp_server.c  topology/topology.o common/seg.o common/pkt.o common/common.o utils/concurrent.o -o server/stress_server.out

clean:
	rm -rf common/*.o
	rm -rf topology/*.o
	rm -rf utils/*.o
	rm -rf son/*.o
	rm -rf son/son
	rm -rf sip/*.o
	rm -rf sip/sip 
	rm -rf client/*.out
	rm -rf server/*.out
	rm -rf server/*.txt